dat_general=[];str=[];xs=[];Disp=[];EX_general=[];DX_general=[];
dat_ori=[];
n=60;
v=0;
dt=1;
delta_disp=5000;
x_lim=300;
s_dat=[];

for i=15:n
Pic_Num=delta_disp*i;
   
    
    dat=load(strcat('scr_5.Statistical_data_concentration_X_',int2str(Pic_Num),'.sta'));
    [nx,ny]=size(dat);
dat1=dat;


%=============================
%=======SHIFTING==============

dat=[];
for i=x_lim+1:nx
    dat=[dat;dat1(i)];
end
for i=1:x_lim
    dat=[dat;dat1(i)];
end
%==============================

dat_ori=[dat_ori,dat];


sum_dat=0;
for j=1:nx
    sum_dat=sum_dat+dat(j);
end
s_dat=[s_dat,sum_dat];

dat=dat/(sum_dat);
xx=1:nx;
EX=xx*dat;EX_general=[EX_general,EX];
DX=xx.^2*dat-EX^2;DX_general=[DX_general,DX];
Disp=[Disp,DX];

end

% K=[];diff=[];
% for i=21:n+1
%     K=[K,(DX_general(i)-DX_general(i-1))*0.5/(2000*1)];
%     diff=[diff,DX_general(i)-DX_general(i-1)];
% end


%plot (K);

fitx=5;
fity=40;

figure
plot (Disp);

x=fitx:fity;
a=polyfit(x,Disp(fitx:fity)/(delta_disp*2),1);
figure
plot (x,Disp(fitx:fity)/(delta_disp*2));
hold on
plot (x,a(1)*x+a(2),'-*');
string2=strcat('a=',num2str(a(1)));
legend (string2)
hold off
 



